package com.liang.design.event;

import com.liang.design.ICouponDiscount;

import java.math.BigDecimal;

/**
 * @author lsm
 * @ClassName ZJCouponDiscount.java
 * @Description 直减
 * @createTime 2023年12月06日 16:47:00
 */
public class ZJCouponDiscount implements ICouponDiscount<Double> {

    /**
     * 直减计算
     * 1. 使⽤用商品价格减去优惠价格
     * 2. 最低⽀支付⾦金金额1元
     */
    public BigDecimal discountAmount(Double couponInfo, BigDecimal skuPrice) {
        BigDecimal discountAmount = skuPrice.subtract(new BigDecimal(couponInfo));
        if (discountAmount.compareTo(BigDecimal.ZERO) < 1)
            return BigDecimal.ONE;
        return discountAmount;
    }

}
